package org.barad.architecture.analyzer.archpad.xml.handler;

import java.util.LinkedList;

import org.barad.architecture.analyzer.properties.bind.Component;
import org.barad.architecture.analyzer.properties.bind.Propertiez;
import org.barad.architecture.analyzer.archpad.util.Util;

/**
 * Handler responsible for parsing of XML file that contains
 * specification of the model components.
 * 
 * @author svetoslavganov@gmail.com (Svetoslav R. Ganov)
 *
 */
public class PropertiesHandler {
	
	/**
	 * Parses the file passed as a JAXB object.
	 * 
	 * @param jaxbObject The JAXB object
	 * @return Map with class/icon pairs
	 */
	public void process(Object jaxbObject) {
		LinkedList<ComponentDescriptor> loadedList = new LinkedList<ComponentDescriptor>(); 
		Propertiez properties = (Propertiez)jaxbObject;
		Util.setModelName(properties.getModel().getClazz());
		for (Component component: properties.getComponent()) {
			ComponentDescriptor descriptor = new ComponentDescriptor(component.getClazz(), component.getIcon(), component.getToolTipText(), component.isLinkMandatory());
			loadedList.add(descriptor);	 
		}
		Util.setComponentProperties(loadedList);
	}
}
